Mission Editor rewards and subfolder controller and view restructure

James Peret 10 years ago
parent
commit
6b13537083
34 changed files with 320 additions and 93 deletions
  1. 3 1
      app/assets/stylesheets/mission_editor.css.less
  2. 77 0
      app/controllers/mission_editor/mission_agents_controller.rb
  3. 3 0
      app/controllers/mission_editor/mission_editor_controller.rb
  4. 9 5
      app/controllers/rewards_controller.rb
  5. 2 0
      app/helpers/mission_agents_helper.rb
  6. 1 1
      app/views/blog_posts/_form.html.erb
  7. 10 0
      app/views/mission_editor/mission_agents/_form.html.erb
  8. 6 0
      app/views/mission_editor/mission_agents/edit.html.erb
  9. 25 0
      app/views/mission_editor/mission_agents/index.html.erb
  10. 4 0
      app/views/mission_editor/mission_agents/index.json.jbuilder
  11. 5 0
      app/views/mission_editor/mission_agents/new.html.erb
  12. 4 0
      app/views/mission_editor/mission_agents/show.html.erb
  13. 1 0
      app/views/mission_editor/mission_agents/show.json.jbuilder
  14. 7 23
      app/views/rewards/_form.html.erb
  15. 43 0
      app/views/mission_editor/rewards/edit.html.erb
  16. 7 14
      app/views/rewards/index.html.erb
  17. 0 0
      app/views/mission_editor/rewards/index.json.jbuilder
  18. 0 1
      app/views/rewards/new.html.erb
  19. 0 0
      app/views/mission_editor/rewards/show.html.erb
  20. 0 0
      app/views/mission_editor/rewards/show.json.jbuilder
  21. 8 8
      app/views/missions/_form.html.erb
  22. 4 4
      app/views/missions/_mission_editor_tabs.html.erb
  23. 2 2
      app/views/missions/_mission_image_uploader.html.erb
  24. 2 2
      app/views/missions/edit.html.erb
  25. 2 2
      app/views/missions/new.html.erb
  26. 0 6
      app/views/rewards/edit.html.erb
  27. 1 1
      app/views/uploads/_form.html.erb
  28. 2 1
      config/locales/en.yml
  29. 16 10
      config/locales/mission.en.yml
  30. 16 10
      config/locales/mission.pt-BR.yml
  31. 2 1
      config/locales/pt-BR.yml
  32. 5 1
      config/routes.rb
  33. 49 0
      test/controllers/mission_agents_controller_test.rb
  34. 4 0
      test/helpers/mission_agents_helper_test.rb

+ 3 - 1
app/assets/stylesheets/mission_editor.css.less

@@ -122,11 +122,13 @@ span.btn-file .form-group {
122 122
 		border: 2px dashed #AFB4BF;
123 123
 		border-radius: 10px;
124 124
 		text-align: center;
125
-		i { font-size: 230px; color: #AFB4BF; }
125
+		i { font-size: 220px; color: #AFB4BF; }
126 126
 	}
127 127
 	.centered-editor-new {
128 128
 		width: 350px;
129 129
 		margin-left: auto;
130 130
 		margin-right: auto;
131
+		p { margin-top: -15px;}
132
+		i { font-size: 210px;}
131 133
 	}
132 134
 }

+ 77 - 0
app/controllers/mission_editor/mission_agents_controller.rb

@@ -0,0 +1,77 @@
1
+class MissionEditor::MissionAgentsController < MissionEditorController
2
+  
3
+  MissionAgentsController.append_view_path("views/mission_editor/mission_agents")
4
+  
5
+  before_action :set_mission_agent, only: [:show, :edit, :update, :destroy]
6
+
7
+  # GET /mission_agents
8
+  # GET /mission_agents.json
9
+  def index
10
+    @mission_agents = MissionAgent.all
11
+  end
12
+
13
+  # GET /mission_agents/1
14
+  # GET /mission_agents/1.json
15
+  def show
16
+  end
17
+
18
+  # GET /mission_agents/new
19
+  def new
20
+    @mission_agent = MissionAgent.new
21
+  end
22
+
23
+  # GET /mission_agents/1/edit
24
+  def edit
25
+  end
26
+
27
+  # POST /mission_agents
28
+  # POST /mission_agents.json
29
+  def create
30
+    @mission_agent = MissionAgent.new(mission_agent_params)
31
+
32
+    respond_to do |format|
33
+      if @mission_agent.save
34
+        format.html { redirect_to @mission_agent, notice: 'Mission agent was successfully created.' }
35
+        format.json { render action: 'show', status: :created, location: @mission_agent }
36
+      else
37
+        format.html { render action: 'new' }
38
+        format.json { render json: @mission_agent.errors, status: :unprocessable_entity }
39
+      end
40
+    end
41
+  end
42
+
43
+  # PATCH/PUT /mission_agents/1
44
+  # PATCH/PUT /mission_agents/1.json
45
+  def update
46
+    respond_to do |format|
47
+      if @mission_agent.update(mission_agent_params)
48
+        format.html { redirect_to @mission_agent, notice: 'Mission agent was successfully updated.' }
49
+        format.json { head :no_content }
50
+      else
51
+        format.html { render action: 'edit' }
52
+        format.json { render json: @mission_agent.errors, status: :unprocessable_entity }
53
+      end
54
+    end
55
+  end
56
+
57
+  # DELETE /mission_agents/1
58
+  # DELETE /mission_agents/1.json
59
+  def destroy
60
+    @mission_agent.destroy
61
+    respond_to do |format|
62
+      format.html { redirect_to mission_agents_url }
63
+      format.json { head :no_content }
64
+    end
65
+  end
66
+
67
+  private
68
+    # Use callbacks to share common setup or constraints between actions.
69
+    def set_mission_agent
70
+      @mission_agent = MissionAgent.find(params[:id])
71
+    end
72
+
73
+    # Never trust parameters from the scary internet, only allow the white list through.
74
+    def mission_agent_params
75
+      params[:mission_agent]
76
+    end
77
+end

+ 3 - 0
app/controllers/mission_editor/mission_editor_controller.rb

@@ -0,0 +1,3 @@
1
+class MissionEditorController < ApplicationController
2
+  
3
+end

+ 9 - 5
app/controllers/rewards_controller.rb

@@ -1,4 +1,7 @@
1
-class RewardsController < ApplicationController
1
+class MissionEditor::RewardsController < ApplicationController
2
+  
3
+ 
4
+  
2 5
   before_action :set_reward, only: [:edit, :update, :destroy]
3 6
   before_action :set_mission
4 7
 
@@ -21,10 +24,10 @@ class RewardsController < ApplicationController
21 24
   # POST /rewards.json
22 25
   def create
23 26
     @reward = Reward.new(reward_params)
24
-
27
+    @reward.mission = @mission
25 28
     respond_to do |format|
26 29
       if @reward.save
27
-        format.html { redirect_to @reward, notice: 'Reward was successfully created.' }
30
+        format.html { redirect_to rewards_path, notice: 'Reward was successfully created.' }
28 31
         format.json { render action: 'show', status: :created, location: @reward }
29 32
       else
30 33
         format.html { render action: 'new' }
@@ -36,9 +39,10 @@ class RewardsController < ApplicationController
36 39
   # PATCH/PUT /rewards/1
37 40
   # PATCH/PUT /rewards/1.json
38 41
   def update
42
+    @reward.mission = @mission
39 43
     respond_to do |format|
40 44
       if @reward.update(reward_params)
41
-        format.html { redirect_to @reward, notice: 'Reward was successfully updated.' }
45
+        format.html { redirect_to rewards_path, notice: 'Reward was successfully updated.' }
42 46
         format.json { head :no_content }
43 47
       else
44 48
         format.html { render action: 'edit' }
@@ -69,6 +73,6 @@ class RewardsController < ApplicationController
69 73
 
70 74
     # Never trust parameters from the scary internet, only allow the white list through.
71 75
     def reward_params
72
-      params[:reward]
76
+      params.require(:reward).permit(:title, :description, :img)
73 77
     end
74 78
 end

+ 2 - 0
app/helpers/mission_agents_helper.rb

@@ -0,0 +1,2 @@
1
+module MissionAgentsHelper
2
+end

+ 1 - 1
app/views/blog_posts/_form.html.erb

@@ -40,7 +40,7 @@
40 40
 	<div class="form-actions" style="margin: 0px;">
41 41
 		<%= f.submit (t 'blog.submit'), class: 'btn btn-success' %>
42 42
 		<%= link_to 'Show', @blog_post, class: 'btn' if action_name == 'edit' %>
43
-		<%= link_to (t 'blog.back'), admin_posts_path, class: 'btn btn-link' %>
43
+		<%= link_to (t 'nav.back'), admin_posts_path, class: 'btn btn-link' %>
44 44
 	</div>
45 45
 
46 46
 	<% end %>

+ 10 - 0
app/views/mission_editor/mission_agents/_form.html.erb

@@ -0,0 +1,10 @@
1
+<%= simple_form_for(@mission_agent) do |f| %>
2
+  <%= f.error_notification %>
3
+
4
+  <div class="form-inputs">
5
+  </div>
6
+
7
+  <div class="form-actions">
8
+    <%= f.button :submit %>
9
+  </div>
10
+<% end %>

+ 6 - 0
app/views/mission_editor/mission_agents/edit.html.erb

@@ -0,0 +1,6 @@
1
+<h1>Editing mission_agent</h1>
2
+
3
+<%= render 'form' %>
4
+
5
+<%= link_to 'Show', @mission_agent %> |
6
+<%= link_to 'Back', mission_agents_path %>

+ 25 - 0
app/views/mission_editor/mission_agents/index.html.erb

@@ -0,0 +1,25 @@
1
+<h1>Listing mission_agents</h1>
2
+
3
+<table>
4
+  <thead>
5
+    <tr>
6
+      <th></th>
7
+      <th></th>
8
+      <th></th>
9
+    </tr>
10
+  </thead>
11
+
12
+  <tbody>
13
+    <% @mission_agents.each do |mission_agent| %>
14
+      <tr>
15
+        <td><%= link_to 'Show', mission_agent %></td>
16
+        <td><%= link_to 'Edit', edit_mission_agent_path(mission_agent) %></td>
17
+        <td><%= link_to 'Destroy', mission_agent, method: :delete, data: { confirm: 'Are you sure?' } %></td>
18
+      </tr>
19
+    <% end %>
20
+  </tbody>
21
+</table>
22
+
23
+<br>
24
+
25
+<%= link_to 'New Mission agent', new_mission_agent_path %>

+ 4 - 0
app/views/mission_editor/mission_agents/index.json.jbuilder

@@ -0,0 +1,4 @@
1
+json.array!(@mission_agents) do |mission_agent|
2
+  json.extract! mission_agent, :id
3
+  json.url mission_agent_url(mission_agent, format: :json)
4
+end

+ 5 - 0
app/views/mission_editor/mission_agents/new.html.erb

@@ -0,0 +1,5 @@
1
+<h1>New mission_agent</h1>
2
+
3
+<%= render 'form' %>
4
+
5
+<%= link_to 'Back', mission_agents_path %>

+ 4 - 0
app/views/mission_editor/mission_agents/show.html.erb

@@ -0,0 +1,4 @@
1
+<p id="notice"><%= notice %></p>
2
+
3
+<%= link_to 'Edit', edit_mission_agent_path(@mission_agent) %> |
4
+<%= link_to 'Back', mission_agents_path %>

+ 1 - 0
app/views/mission_editor/mission_agents/show.json.jbuilder

@@ -0,0 +1 @@
1
+json.extract! @mission_agent, :id, :created_at, :updated_at

+ 7 - 23
app/views/rewards/_form.html.erb

@@ -1,28 +1,16 @@
1
-<%= bootstrap_form_for(@reward) do |f| %>
2
- <%= f.alert_message "Please fix the errors below." %>
3
-
4
-  <div class="form-inputs">
5
-  </div>
6
-
7
-  <div class="form-actions">
8
-    <%= f.submit %>
9
-  </div>
10
-<% end %>
11
-
12
-
13
-<%= bootstrap_form_for(@reward) do |f| %>
1
+<%= bootstrap_form_for(@reward, id: @mission.slug) do |f| %>
14 2
   <%= f.alert_message "Please fix the errors below." %>
15 3
   <%= content_tag(:div, class: 'panel panel-default') do %>
16 4
   	<%= content_tag(:div, class: 'panel-body white-bg') do %>
17 5
 		<%= content_tag(:div, class: "panel-content") do %>
18 6
 			<%= content_tag(:div, class: "panel-text") do %>
19 7
 				<%= content_tag(:div, class: "form-inputs") do %>
20
-				    <%= f.text_field :title, label: (t 'mission_editor.reward_title'), class: 'input-block-level' %>
21
-				    <%= f.text_area :description, label: (t 'mission_editor.reward_description'), class: 'input-block-level', rows: 5 %>
8
+				    <%= f.text_field :title, label: (t 'mission_editor.rewards.reward_title'), class: 'input-block-level' %>
9
+				    <%= f.text_area :description, label: (t 'mission_editor.mission_details.reward_description'), class: 'input-block-level', rows: 5 %>
22 10
 				    
23 11
 					
24 12
 					<%= content_tag(:div, class: 'form-group', style: 'padding-bottom: 2px;') do %>
25
-						<%= content_tag(:label, (t 'mission_editor.cover_image'), class: 'control-label', for: 'cover_image')%>
13
+						<%= content_tag(:label, (t 'mission_editor.reward.image'), class: 'control-label', for: 'cover_image')%>
26 14
 						<%= content_tag(:div, class: 'fileupload fileupload-new', data: { provides: 'fileupload' } ) do %>
27 15
 							<%= content_tag(:div, class: 'fileupload-preview cover-fileupload-preview thumbnail', data: { trigger: 'fileinput' } ) do %>
28 16
 								<%= image_tag @reward.img.to_s if @reward.img? %>
@@ -31,7 +19,7 @@
31 19
 								<%= content_tag(:span, '', class: 'fileinput-new') %>
32 20
 								<%= content_tag(:span, '', class: 'fileinput-exists') %>
33 21
 
34
-								<%= f.file_field :img, class: 'hidden ', layout: :inline,  label: (t 'mission_editor.select_image') %>
22
+								<%= f.file_field :img, class: 'hidden ', layout: :inline,  label: (t 'mission_editor.mission_details.select_image') %>
35 23
 							<% end %>
36 24
 						<% end %>
37 25
 					<% end %>
@@ -44,14 +32,10 @@
44 32
   <% end %>
45 33
   <%= content_tag(:div, class: "form-submit-center") do %>
46 34
   	<%= content_tag(:p) do %>
47
-		<% if params[:action] == 'edit' %>
48
-			<%= f.submit (t 'mission_editor.save_reward'), class: 'btn btn-large btn-success spacer-left-small' %>
49
-		<% else%>
50
-  			<%= f.submit (t 'mission_editor.create_reward'), class: 'btn btn-large btn-success all-caps' %>
51
-		<% end %>
35
+		<%= f.submit (t 'mission_editor.rewards.save_reward'), class: 'btn btn-large btn-success spacer-left-small' %>
52 36
 	<% end %>
53 37
 	<%= content_tag(:p) do %>
54
-		<%= link_to 'back', missions_path, class: 'btn btn-link btn-danger' %>
38
+		<%= link_to (t'nav.back'), rewards_path, class: 'btn btn-link btn-danger' %>
55 39
 	<% end %>
56 40
   <% end %>
57 41
 <% end %>

+ 43 - 0
app/views/mission_editor/rewards/edit.html.erb

@@ -0,0 +1,43 @@
1
+
2
+
3
+<% title "#{t 'mission_editor.edit_reward'} - #{@config.website_name}" %>
4
+
5
+<%= render :partial => 'missions/mission_editor_tabs' %>
6
+
7
+<%= content_tag(:div, class: 'container-bg') do %>
8
+	<%= content_tag(:div, class: 'container container-bg mission-detail-container') do %>
9
+		<%= content_tag(:div, class: 'row') do %>
10
+			<%= content_tag(:div, class: 'span12') do %>
11
+				
12
+				<%= content_tag(:div, class: 'page-header page-header-type') do %>
13
+					<%= content_tag(:small, @mission.title + ':') %>
14
+					<%= content_tag(:h1) do %>
15
+						<%= t 'mission_editor.edit_reward' %>
16
+					<% end %>
17
+				<% end %>
18
+				
19
+			<% end%>
20
+		<% end %>
21
+		<%= content_tag(:div, class: 'row') do %>
22
+			<%= content_tag(:div, class: 'span8') do %>
23
+			
24
+				<%= render 'form' %>
25
+			
26
+			<% end %>
27
+			<% # Sidebar %>
28
+			<%= content_tag(:div, class: 'span4 sidebar') do %>
29
+			     <%= content_tag(:div, class: 'panel panel-default sidebar-carret') do %>
30
+			     	<%= content_tag(:div, class: 'panel-body white-bg') do %>
31
+				   		<%= content_tag(:div, class: "panel-content") do %>
32
+				   			<%= content_tag(:div, class: "panel-text") do %>
33
+								<%= content_tag(:h3, (t 'mission_editor.mission_details_help_title')) %>
34
+								<%= content_tag(:div, (t 'mission_editor.mission_details_help').html_safe, class: 'small-text') %>
35
+							<% end %>
36
+						<% end %>
37
+					<% end %>
38
+				<% end %>
39
+			<% end %>
40
+			
41
+		<% end %>
42
+	<% end %>			
43
+<% end %>

+ 7 - 14
app/views/rewards/index.html.erb

@@ -8,7 +8,7 @@
8 8
 				<%= content_tag(:div, class: 'page-header page-header-type') do %>
9 9
 					<%= content_tag(:small, @mission.title + ':') %>
10 10
 					<%= content_tag(:h1) do %>
11
-						<%= t 'mission.editor.rewards' %>
11
+						<%= t 'mission_editor.rewards.page_title' %>
12 12
 					<% end %>
13 13
 				<% end %>
14 14
 				
@@ -24,25 +24,18 @@
24 24
 								<%= content_tag(:p, content_tag(:small, reward.title)) %>
25 25
 							<% end %>
26 26
 							<%= content_tag(:p, reward.description) %>
27
-							<%= content_tag(:p, class: 'rewards-details ') do %>
28
-								<%= content_tag(:span, (t 'mission.agents')+': ', class: 'reward-agent-title') %>
29
-								<% agent_counter = 1 %>
30
-								<% reward.mission_agents.each do |agent| %>		
31
-									<%= content_tag(:span, (link_to agent.role.to_s, mission_agent_details_path(agent: agent.id, id: agent.mission)) , class: 'reward-agent-role') %>
32
-									<% if agent_counter < reward.mission_agents.count %>
33
-										<%= ', ' %>
34
-									<% end %>
35
-									<% agent_counter = agent_counter + 1 %>
36
-								<% end %>
27
+							<%= content_tag(:p, class: 'centered') do %>
28
+								<%= link_to( (t 'nav.edit'), edit_reward_path(reward), class: 'btn')%>
37 29
 							<% end %>
38 30
 						<% end %>
39 31
 					<% end %>
40 32
 				<% end %>
41
-				<% @rewards.count == 0 ? centered = ['span12', 'centered-editor-new'] : centered = ['span4', ''] %>
33
+				<% @rewards.count == 0 ? centered = ['span12', 'centered-editor-new', "<p>#{t'mission_editor.rewards.no_rewards'}</p>"] : centered = ['span4', '', '<br>'] %>
42 34
 				<%= content_tag(:li, class: centered[0] ) do %>
43 35
 					<%= content_tag(:div, class: "editor-reward-new #{centered[1]}") do %>
44 36
 						<i class="icon-reward"></i><br>
45
-						<%= link_to 'Add Reward', new_reward_path(@mission), class: 'btn' %>
37
+						<%= centered[2].html_safe %>
38
+						<%= link_to (t'mission_editor.rewards.add'), new_reward_path(@mission), class: 'btn' %>
46 39
 					<% end %>
47 40
 				<% end %>
48 41
 			<% end %>
@@ -55,7 +48,7 @@
55 48
 						<%= link_to((t'nav.next'), '#', class: 'btn btn-success')%>
56 49
 					<% end %>
57 50
 					<%= content_tag(:p) do %>
58
-						<%= link_to 'cancel', missions_path, class: 'btn btn-link btn-danger' %>
51
+						<%= link_to (t'mission_editor.continue_later'), missions_path, class: 'btn btn-link btn-danger' %>
59 52
 					<% end %>
60 53
 				<% end %>
61 54
 			<% end %>

app/views/rewards/index.json.jbuilder → app/views/mission_editor/rewards/index.json.jbuilder


+ 0 - 1
app/views/rewards/new.html.erb

@@ -20,7 +20,6 @@
20 20
 			<%= content_tag(:div, class: 'span8') do %>
21 21
 			
22 22
 				<%= render 'form' %>
23
-				<%= link_to 'Back', rewards_path(@mission) %>
24 23
 			
25 24
 			<% end %>
26 25
 			<% # Sidebar %>

app/views/rewards/show.html.erb → app/views/mission_editor/rewards/show.html.erb


app/views/rewards/show.json.jbuilder → app/views/mission_editor/rewards/show.json.jbuilder


+ 8 - 8
app/views/missions/_form.html.erb

@@ -5,14 +5,14 @@
5 5
 		<%= content_tag(:div, class: "panel-content") do %>
6 6
 			<%= content_tag(:div, class: "panel-text") do %>
7 7
 				<%= content_tag(:div, class: "form-inputs") do %>
8
-				    <%= f.text_field :title, label: (t 'mission_editor.mission_title'), class: 'input-block-level' %>
9
-				    <%= f.text_field :objective, label: (t 'mission_editor.mission_objective'), class: 'input-block-level' %>
10
-				    <%= f.text_area :briefing, label: (t 'mission_editor.mission_briefing'), class: 'input-block-level', rows: 10 %>
11
-				    <%= f.select :language, [[(t 'mission_editor.en'), 'en'], [(t 'mission_editor.pt-BR'), 'pt-BR']], { label: (t 'mission_editor.language') }, { class: "selectpicker" } %>
8
+				    <%= f.text_field :title, label: (t 'mission_editor.mission_details.mission_title'), class: 'input-block-level' %>
9
+				    <%= f.text_field :objective, label: (t 'mission_editor.mission_details.mission_objective'), class: 'input-block-level' %>
10
+				    <%= f.text_area :briefing, label: (t 'mission_editor.mission_details.mission_briefing'), class: 'input-block-level', rows: 10 %>
11
+				    <%= f.select :language, [[(t 'mission_editor.mission_details.en'), 'en'], [(t 'mission_editor.mission_details.pt-BR'), 'pt-BR']], { label: (t 'mission_editor.mission_details.language') }, { class: "selectpicker" } %>
12 12
 					<%= render :partial => 'mission_image_uploader', locals: { mission: @mission, f: f } %>
13 13
 					<%= content_tag(:div, '', class: 'inline-form-line') do%>
14
-						<%= f.select :duration_scale, [[(t 'time.days'), 'days'], [(t 'time.hours'), 'hours']], { label: (t 'mission_editor.mission_duration') }, { class: "selectpicker", layout: :inlin } %>
15
-						<%= f.text_field :duration_number, hide_label: true, placeholder: (t 'mission_editor.duration') %>
14
+						<%= f.select :duration_scale, [[(t 'time.days'), 'days'], [(t 'time.hours'), 'hours']], { label: (t 'mission_editor.mission_details.mission_duration') }, { class: "selectpicker", layout: :inlin } %>
15
+						<%= f.text_field :duration_number, hide_label: true, placeholder: (t 'mission_editor.mission_details.duration') %>
16 16
 					<% end %>
17 17
 				<% end %>
18 18
 			<% end %>
@@ -22,10 +22,10 @@
22 22
   <%= content_tag(:div, class: "form-submit-center") do %>
23 23
   	<%= content_tag(:p) do %>
24 24
 		<% if params[:action] == 'edit' %>
25
-			<%= f.submit (t 'mission_editor.save'), class: 'btn btn-large btn-success spacer-left-small' %>
25
+			<%= f.submit (t 'mission_editor.mission_details.save'), class: 'btn btn-large btn-success spacer-left-small' %>
26 26
 			<%= link_to((t'nav.next'), rewards_path(@mission), class: 'btn ')%>
27 27
 		<% else%>
28
-  			<%= f.submit (t 'mission_editor.save_and_continue'), class: 'btn btn-large btn-success all-caps' %>
28
+  			<%= f.submit (t 'mission_editor.mission_details.save_and_continue'), class: 'btn btn-large btn-success all-caps' %>
29 29
 		<% end %>
30 30
 	<% end %>
31 31
 	<%= content_tag(:p) do %>

+ 4 - 4
app/views/missions/_mission_editor_tabs.html.erb

@@ -7,19 +7,19 @@
7 7
 				<%= content_tag(:ul, class: 'steps') do %>
8 8
 					<%= content_tag(:li, class: 'step') do %>
9 9
 						<%= content_tag(:div, '1', class: 'circle current') %><br>
10
-						<%= content_tag(:div, (t 'mission_editor.mission_details'), class: 'description current') %>
10
+						<%= content_tag(:div, (t 'mission_editor.mission_details.mission_details'), class: 'description current') %>
11 11
 					<% end %>
12 12
 					<%= content_tag(:li, class: 'step') do %>
13 13
 						<%= content_tag(:div, '2', class: 'circle') %><br>
14
-						<%= content_tag(:div, (t 'mission_editor.rewards'), class: 'description') %>
14
+						<%= content_tag(:div, (t 'mission_editor.mission_details.rewards'), class: 'description') %>
15 15
 					<% end %>
16 16
 					<%= content_tag(:li, class: 'step') do %>
17 17
 						<%= content_tag(:div, '3', class: 'circle') %><br>
18
-						<%= content_tag(:div, (t 'mission_editor.agents'), class: 'description') %>
18
+						<%= content_tag(:div, (t 'mission_editor.mission_details.agents'), class: 'description') %>
19 19
 					<% end %>
20 20
 					<%= content_tag(:li, class: 'step') do %>
21 21
 						<%= content_tag(:div, '4', class: 'circle') %><br>
22
-						<%= content_tag(:div, (t 'mission_editor.launch'), class: 'description') %>
22
+						<%= content_tag(:div, (t 'mission_editor.mission_details.launch'), class: 'description') %>
23 23
 					<% end %>
24 24
 				<% end %>
25 25
 			<% end %>

+ 2 - 2
app/views/missions/_mission_image_uploader.html.erb

@@ -1,5 +1,5 @@
1 1
 <%= content_tag(:div, class: 'form-group', style: 'padding-bottom: 2px;') do %>
2
-	<%= content_tag(:label, (t 'mission_editor.cover_image'), class: 'control-label', for: 'cover_image')%>
2
+	<%= content_tag(:label, (t 'mission_editor.mission_details.cover_image'), class: 'control-label', for: 'cover_image')%>
3 3
 	<%= content_tag(:div, class: 'fileupload fileupload-new', data: { provides: 'fileupload' } ) do %>
4 4
 		<%= content_tag(:div, class: 'fileupload-preview cover-fileupload-preview thumbnail', data: { trigger: 'fileinput' } ) do %>
5 5
 			<%= image_tag mission.cover_img.to_s if mission.cover_img? %>
@@ -8,7 +8,7 @@
8 8
 			<%= content_tag(:span, '', class: 'fileinput-new') %>
9 9
 			<%= content_tag(:span, '', class: 'fileinput-exists') %>
10 10
 
11
-			<%= f.file_field :cover_img, class: 'hidden ', layout: :inline,  label: (t 'mission_editor.select_image') %>
11
+			<%= f.file_field :cover_img, class: 'hidden ', layout: :inline,  label: (t 'mission_editor.mission_details.select_image') %>
12 12
 		<% end %>
13 13
 	<% end %>
14 14
 <% end %>

+ 2 - 2
app/views/missions/edit.html.erb

@@ -28,8 +28,8 @@
28 28
 			     	<%= content_tag(:div, class: 'panel-body white-bg') do %>
29 29
 				   		<%= content_tag(:div, class: "panel-content") do %>
30 30
 				   			<%= content_tag(:div, class: "panel-text") do %>
31
-								<%= content_tag(:h3, (t 'mission_editor.mission_details_help_title')) %>
32
-								<%= content_tag(:div, (t 'mission_editor.mission_details_help').html_safe, class: 'small-text') %>
31
+								<%= content_tag(:h3, (t 'mission_editor.mission_details.mission_details_help_title')) %>
32
+								<%= content_tag(:div, (t 'mission_editor.mission_details.mission_details_help').html_safe, class: 'small-text') %>
33 33
 							<% end %>
34 34
 						<% end %>
35 35
 					<% end %>

+ 2 - 2
app/views/missions/new.html.erb

@@ -27,8 +27,8 @@
27 27
 			     	<%= content_tag(:div, class: 'panel-body white-bg') do %>
28 28
 				   		<%= content_tag(:div, class: "panel-content") do %>
29 29
 				   			<%= content_tag(:div, class: "panel-text") do %>
30
-								<%= content_tag(:h3, (t 'mission_editor.mission_details_help_title')) %>
31
-								<%= content_tag(:div, (t 'mission_editor.mission_details_help').html_safe, class: 'small-text') %>
30
+								<%= content_tag(:h3, (t 'mission_editor.mission_details.mission_details_help_title')) %>
31
+								<%= content_tag(:div, (t 'mission_editor.mission_details.mission_details_help').html_safe, class: 'small-text') %>
32 32
 							<% end %>
33 33
 						<% end %>
34 34
 					<% end %>

+ 0 - 6
app/views/rewards/edit.html.erb

@@ -1,6 +0,0 @@
1
-<h1>Editing reward</h1>
2
-
3
-<%= render 'form' %>
4
-
5
-<%= link_to 'Show', @reward %> |
6
-<%= link_to 'Back', rewards_path %>

+ 1 - 1
app/views/uploads/_form.html.erb

@@ -35,7 +35,7 @@
35 35
 	<div class="form-actions" style="margin: 0px;">
36 36
 		<%= f.submit (t 'blog.submit'), class: 'btn btn-success' %>
37 37
 		<%= link_to 'Show', @upload, class: 'btn' if action_name == 'edit' %>
38
-		<%= link_to (t 'blog.back'), admin_files_path, class: 'btn btn-link' %>
38
+		<%= link_to (t 'nav.back'), admin_files_path, class: 'btn btn-link' %>
39 39
 	</div>
40 40
 
41 41
 	<% end %>

+ 2 - 1
config/locales/en.yml

@@ -250,7 +250,9 @@ en:
250 250
     login: Login
251 251
     signup: Sign Up
252 252
     back: Back
253
+    next: Next
253 254
     edit: Edit
255
+    cancel: Cancel
254 256
   blog:
255 257
     by: By
256 258
     ago: ago
@@ -265,7 +267,6 @@ en:
265 267
     description: Description
266 268
     content: Content
267 269
     submit: Save
268
-    back: Back
269 270
     latest_posts: Latest Posts
270 271
     more_posts: More posts
271 272
   contact:

+ 16 - 10
config/locales/mission.en.yml

@@ -15,13 +15,19 @@ en:
15 15
     dashboard: 'Dashboard'
16 16
     account: 'Account'
17 17
   mission_editor:
18
-    save: 'Save'
19
-    save_and_continue: 'Save & Continue'
20
-    select_image: 'Select Image'
21
-    language: 'Language'
22
-    en: 'English'
23
-    pt-BR: 'Portuguese'
24
-    mission_duration: 'Mission Duration'
25
-    duration: 'Type in a number'
26
-    mission_details_help_title: 'Mission Details'
27
-    mission_details_help: '<p>Fill out all the basic mission details. The video is not necessary.</p><p>Give your mission a good descriptive title.</p><p>What is going to be achieved in this mission? Write that as the mission obective.</p><p>Missions are going to be filtered to users based on their language settings.</p><p>Paste the URL of a youtube or vimeo video for your mission briefing. Make it 1-5 minutes long, tell about the mission objective, the briefing, the timetable, what agents the mission needs, what are they going to have to do and the rewards. Make it personal. Give a good cause for your mission.</p><p>In the mission briefing, tell the agents how things are going to work out during the mission. You dont have to be specific here, but try to tell everyone what is going to happen and a summary of what each agent is going to do.</p><p>After completing the form, save and continue to add rewards and agents to the mission.</p><p>Before the mission is launched, only the you can see the mission and edit its content. After the mission is launched, most of the mission details wont be able to be edited.</p>'
18
+    continue_later: 'continue later'
19
+    mission_details:
20
+      save: 'Save'
21
+      save_and_continue: 'Save & Continue'
22
+      select_image: 'Select Image'
23
+      language: 'Language'
24
+      en: 'English'
25
+      pt-BR: 'Portuguese'
26
+      mission_duration: 'Mission Duration'
27
+      duration: 'Type in a number'
28
+      mission_details_help_title: 'Mission Details'
29
+      mission_details_help: '<p>Fill out all the basic mission details. The video is not necessary.</p><p>Give your mission a good descriptive title.</p><p>What is going to be achieved in this mission? Write that as the mission obective.</p><p>Missions are going to be filtered to users based on their language settings.</p><p>Paste the URL of a youtube or vimeo video for your mission briefing. Make it 1-5 minutes long, tell about the mission objective, the briefing, the timetable, what agents the mission needs, what are they going to have to do and the rewards. Make it personal. Give a good cause for your mission.</p><p>In the mission briefing, tell the agents how things are going to work out during the mission. You dont have to be specific here, but try to tell everyone what is going to happen and a summary of what each agent is going to do.</p><p>After completing the form, save and continue to add rewards and agents to the mission.</p><p>Before the mission is launched, only the you can see the mission and edit its content. After the mission is launched, most of the mission details wont be able to be edited.</p>'
30
+    rewards:
31
+      page_title: 'Rewards'
32
+      save_reward: 'Save Reward'
33
+      add: 'Add Reward'

+ 16 - 10
config/locales/mission.pt-BR.yml

@@ -15,13 +15,19 @@ pt-BR:
15 15
     dashboard: 'Painel'
16 16
     account: 'Conta'
17 17
   mission_editor:
18
-    save: 'Salvar'
19
-    save_and_continue: 'Salvar & Continuar'
20
-    select_image: 'Select Image'
21
-    language: 'Lingua'
22
-    en: 'Inglês'
23
-    pt-BR: 'Português'
24
-    mission_duration: 'Tempo de duração da missão'
25
-    duration: 'Digite um número...'
26
-    mission_details_help_title: 'Mission Details'
27
-    mission_details_help: '<p>Fill out all the basic mission details. The video is not necessary.</p><p>Give your mission a good descriptive title.</p><p>What is going to be achieved in this mission? Write that as the mission obective.</p><p>Missions are going to be filtered to users based on their language settings.</p><p>Paste the URL of a youtube or vimeo video for your mission briefing. Make it 1-5 minutes long, tell about the mission objective, the briefing, the timetable, what agents the mission needs, what are they going to have to do and the rewards. Make it personal. Give a good cause for your mission.</p><p>In the mission briefing, tell the agents how things are going to work out during the mission. You dont have to be specific here, but try to tell everyone what is going to happen and a summary of what each agent is going to do.</p><p>After completing the form, save and continue to add rewards and agents to the mission.</p><p>Before the mission is launched, only the you can see the mission and edit its content. After the mission is launched, most of the mission details wont be able to be edited.</p>'
18
+    continue_later: 'continuar depois'
19
+    mission_details:
20
+      save: 'Salvar'
21
+      save_and_continue: 'Salvar & Continuar'
22
+      select_image: 'Select Image'
23
+      language: 'Lingua'
24
+      en: 'Inglês'
25
+      pt-BR: 'Português'
26
+      mission_duration: 'Tempo de duração da missão'
27
+      duration: 'Digite um número...'
28
+      mission_details_help_title: 'Mission Details'
29
+      mission_details_help: '<p>Fill out all the basic mission details. The video is not necessary.</p><p>Give your mission a good descriptive title.</p><p>What is going to be achieved in this mission? Write that as the mission obective.</p><p>Missions are going to be filtered to users based on their language settings.</p><p>Paste the URL of a youtube or vimeo video for your mission briefing. Make it 1-5 minutes long, tell about the mission objective, the briefing, the timetable, what agents the mission needs, what are they going to have to do and the rewards. Make it personal. Give a good cause for your mission.</p><p>In the mission briefing, tell the agents how things are going to work out during the mission. You dont have to be specific here, but try to tell everyone what is going to happen and a summary of what each agent is going to do.</p><p>After completing the form, save and continue to add rewards and agents to the mission.</p><p>Before the mission is launched, only the you can see the mission and edit its content. After the mission is launched, most of the mission details wont be able to be edited.</p>'
30
+    rewards:
31
+      page_title: 'Recompensas'
32
+      save_reward: 'Salvar Recompensa'
33
+      add: 'Adicionar Recompensa'

+ 2 - 1
config/locales/pt-BR.yml

@@ -252,7 +252,9 @@ pt-BR:
252 252
     login: Entrar
253 253
     signup: Cadastro
254 254
     back: Voltar
255
+    next: Próximo
255 256
     edit: Editar
257
+    cancel: Cancelar
256 258
   blog:
257 259
     by: Por
258 260
     ago: atras
@@ -267,7 +269,6 @@ pt-BR:
267 269
     description: Descrição
268 270
     content: Conteúdo
269 271
     submit: Salvar
270
-    back: Voltar
271 272
     latest_posts: Últimos Posts
272 273
     more_posts: Mais posts
273 274
   contact:

+ 5 - 1
config/routes.rb

@@ -36,7 +36,11 @@ Avalanche2::Application.routes.draw do
36 36
   
37 37
   # Mission Editor
38 38
   get    'missions/:id/editor' => 'missions#edit', as: :mission_editor
39
-  resources :rewards, path: 'missions/:id/editor/rewards'
39
+  scope 'missions/:id/editor' do
40
+    resources :rewards, :controller => "mission_editor/rewards"
41
+    resources :mission_agents, :controller => "mission_editor/agents"
42
+  end
43
+  
40 44
   # get    'missions/:id/editor/rewards' => 'rewards#index', as: :mission_editor_rewards_list
41 45
   # get    'missions/:id/editor/rewards/new' => 'rewards#new', as: :mission_editor_new_reward
42 46
   # post   'missions/:id/editor/rewards/create' => 'rewards#create', as: :mission_editor_create_reward

+ 49 - 0
test/controllers/mission_agents_controller_test.rb

@@ -0,0 +1,49 @@
1
+require 'test_helper'
2
+
3
+class MissionAgentsControllerTest < ActionController::TestCase
4
+  setup do
5
+    @mission_agent = mission_agents(:one)
6
+  end
7
+
8
+  test "should get index" do
9
+    get :index
10
+    assert_response :success
11
+    assert_not_nil assigns(:mission_agents)
12
+  end
13
+
14
+  test "should get new" do
15
+    get :new
16
+    assert_response :success
17
+  end
18
+
19
+  test "should create mission_agent" do
20
+    assert_difference('MissionAgent.count') do
21
+      post :create, mission_agent: {  }
22
+    end
23
+
24
+    assert_redirected_to mission_agent_path(assigns(:mission_agent))
25
+  end
26
+
27
+  test "should show mission_agent" do
28
+    get :show, id: @mission_agent
29
+    assert_response :success
30
+  end
31
+
32
+  test "should get edit" do
33
+    get :edit, id: @mission_agent
34
+    assert_response :success
35
+  end
36
+
37
+  test "should update mission_agent" do
38
+    patch :update, id: @mission_agent, mission_agent: {  }
39
+    assert_redirected_to mission_agent_path(assigns(:mission_agent))
40
+  end
41
+
42
+  test "should destroy mission_agent" do
43
+    assert_difference('MissionAgent.count', -1) do
44
+      delete :destroy, id: @mission_agent
45
+    end
46
+
47
+    assert_redirected_to mission_agents_path
48
+  end
49
+end

+ 4 - 0
test/helpers/mission_agents_helper_test.rb

@@ -0,0 +1,4 @@
1
+require 'test_helper'
2
+
3
+class MissionAgentsHelperTest < ActionView::TestCase
4
+end